# -*- coding: utf-8 -*-

import sys

import util

from scaws import AWS_CC


APP_PATH = sys.modules['__main__'].WORKER_PATH
TASK_NAME = sys.modules['__main__'].TASK_NAME
TASK_FULL_NAME = sys.modules['__main__'].TASK_FULL_NAME

DATA_PATH = '%s/../scworker_data' % APP_PATH
TASK_PATH = '%s/%s' % (DATA_PATH, TASK_FULL_NAME)
# STATE_DATA_PATH = '%s/state' % (TASK_PATH)
# STATE_FILE_NAME = '%s/state.dat' % STATE_DATA_PATH
LOG_PATH = '%s/log' % (TASK_PATH)

LOGGER_NAME = 'data'
LOGGING_CFG = eval(util.load_file('%s/logging.conf' % util.get_file_path(__file__)).replace('@log_path', LOG_PATH))

PREPARE_FOR_DIRS = [LOG_PATH]

CFG = {
    'processor': 'downloader_recruitment_lagou.Downloader',
    'logger_name': LOGGER_NAME,
    'rest_time': 6,
    'sleep_time': 6,
    'components': [
        {
            'name': 'conveyor',
            'class_name': 'aws_sqs.AwsSqs',
            'cfg': {
                'aws': AWS_CC,
                'queue_used_for_receive': 'recruitment_lagou_task',
                'queue_used_for_send': 'recruitment_lagou_download',
                'allow_create': True,
                'receive_args': {
                    'MaxNumberOfMessages': 1,
                    'WaitTimeSeconds': 6
                }
            }
        },
        {
            'name': 'bucket',
            'class_name': 'aws_s3.AwsS3',
            'cfg': {
                'aws': AWS_CC,
                'bucket_name': 'recruitment',
                'allow_create': True,
                'source': 'lagou',
                'put_event': True,
            }
        }
    ]
}